package me.doublysentinel;

import java.util.Iterator;
import java.util.function.Consumer;

public class Test3 {
    public static void main(String[] args) {
        DoublyLinkedListSentinel dle = new DoublyLinkedListSentinel();

        dle.addFirst(4);
        dle.addFirst(3);
        dle.addFirst(2);
        dle.addFirst(1);

        dle.insert(2, 7);

        dle.remove(0);

        dle.addLast(8);

        Iterator<Integer> it = dle.iterator();
        while (it.hasNext()) {
            System.out.print(it.next() + " ");
        }
        System.out.println();
        System.out.println("---------------------------");

        for (Integer value : dle) {
            System.out.print(value + " ");
        }
        System.out.println();
        System.out.println("---------------------------");

        // lambda表达式
        dle.loop1((Integer value) -> System.out.print(value + " "));
        System.out.println();
        System.out.println("--------------------------");

        // 打印链表
        System.out.println(dle);
    }
}
